

const Cu = Components.utils;
const Ci = Components.interfaces;
const Cc = Components.classes;
function require(url) {
    let scope = {};
    Cu.import(url, scope);
    return scope;
}
let {Clipboard} = require("chrome://jsm/content/Clipboard.js");




window.onload = function () {
    var btn = document.getElementById("copy-to-clipboard-btn");
    btn.focus();
    var textbox = document.getElementById('link');
    textbox.value = window.arguments[0].url;

    var urllen = document.getElementById('text2');
    var text = urllen.firstChild.nodeValue;
    text = text.replace(/\(num\)/, window.arguments[0].url.length+"");
    urllen.firstChild.nodeValue = text;
};


function link0() {
    Clipboard.putString(window.arguments[0].url);
    var textbox = document.getElementById('link');
    textbox.select();
}


function link2() {
    const url = "mailto:?subject=You've received an imacro!&body="+
        window.arguments[0].url;
    var uri = Cc["@mozilla.org/network/simple-uri;1"]
        .getService(Ci.nsIURI);
    uri.spec = url;
    Cc["@mozilla.org/uriloader/external-protocol-service;1"]
        .getService(Ci.nsIExternalProtocolService)
        .loadUrl(uri);
    window.close();
}


function link3() {
    const url = "http://www.addthis.com/bookmark.php?pub=imacrosfx&url="+
        encodeURIComponent(window.arguments[0].url)+
        "&title="+encodeURIComponent(window.arguments[0].name);
    var browser = null;
    if (opener.window.content.document.location == "about:blank")
        opener.window.content.document.location = url;
    else if ( opener.window.getBrowser && (browser = opener.window.getBrowser()) )
        browser.selectedTab = browser.addTab(url);
    window.close();
}


